<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page import="com.onlineMIS.common.Common_util"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>千禧宝贝连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>
<script src='http://127.0.0.1:8000/CLodopfuncs.js'></script>
<script src='http://127.0.0.1:18000/CLodopfuncs.js'></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/conf_files/js/lodop/headLodop.js?v=10.16"></script>
<script>
var isViewPrint = false;
$(document).ready(function(){
	parent.$.messager.progress('close'); 
});
function editBill(){
	document.financeBillForm.action = "<%=request.getContextPath()%>/action/financeHQJSP!editFHQBill";
	document.financeBillForm.submit();
}

function cancelBill(){
	document.financeBillForm.action = "<%=request.getContextPath()%>/action/financeHQJSP!cancelFHQBill";
	document.financeBillForm.submit();
}

function printDocument(isView,orderId){
	isViewPrint = isView;
	 var url = "<%=request.getContextPath()%>/action/financeHQJSON!selectFinanceBill";
	$.post(url,{"formBean.financeBill.id": orderId}, printBackProcess,"json");		
}
/**
 * 打印预览收款单
 */
function printBackProcess(date){
	printCustDocument(isViewPrint,date);
}

function updateFinanceBillComment(){
    var url = "<%=request.getContextPath()%>/action/financeHQJSON!updateFinanceBillComment";
    var orderId = $("#financeBillId").val();
    var comment = $("#comment").val();
    $.post(url,{"formBean.financeBill.id": orderId,"formBean.financeBill.comment": comment}, updateOrderCommentBackProcess,"json");	
}
function updateOrderCommentBackProcess(data){
	var returnValue = data.returnCode;
	if (returnValue == SUCCESS)
	    $.messager.alert('消息', data.message, 'info');
	else 
		$.messager.alert('操作失败', data.message, 'error');
}
</script>
</head>
<body>
	<s:form action="/action/financeHQJSP!editFHQBill" method="POST"
		name="financeBillForm" id="financeBillForm" theme="simple">
		<s:hidden name="formBean.financeBill.id" />
		<input type="hidden" id="financeBillId" value="<s:property value="uiBean.financeBill.id" />">
		<table width="70%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" border="0">
						<tr>
							<td colspan="7">
								<div class="errorAndmes">
									<s:actionerror cssStyle="color:red" />
									<s:actionmessage cssStyle="color:blue" />
								</div>
								<table width="100%" align="left" border="0" id="org_table">
									<tr class="PBAOuterTableTitale">
										<td height="50" colspan="3">客户财务单据明细：<s:property value="uiBean.financeBill.id" />
										</td>
									</tr>
									<tr class="InnerTableContent">
										<td width="180" height="35">单据种类 ： <s:property
												value="uiBean.financeBill.typeHQS" /></td>
										<td width="220">客户 ： <s:property
												value="uiBean.financeBill.cust.name" />
										</td>
										
									</tr>
									<tr class="InnerTableContent">
										<td width="220">创建日期:<s:date
												name="uiBean.financeBill.createDate" format="yyyy-MM-dd HH:mm:ss" /></td>
										<td width="220">更新日期:<s:date
												name="uiBean.financeBill.updateDate" format="yyyy-MM-dd HH:mm:ss" /></td>
										<td width="220">单据日期:<s:date
												name="uiBean.financeBill.billDate" format="yyyy-MM-dd" /></td>
									</tr>
									<tr class="InnerTableContent">
										<td height="25">经手人:<s:property
												value="uiBean.financeBill.creatorHq.user_name" /></td>
										<td>状态 ： <s:if test="uiBean.financeBill.status == 3">
												<font style="color: red"><s:property
														value="uiBean.financeBill.statusS" /></font>
											</s:if>
											<s:else>
												<s:property value="uiBean.financeBill.statusS" />
											</s:else>
										</td>
										<td>备注 ：<input  data-options="prompt:'请输入采购备注信息'"
											id="comment" class="easyui-textbox" style="width: 400px"
											value="<s:property value="uiBean.financeBill.comment" />"> 
								<a id="btn2" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit'" onclick="updateFinanceBillComment();">修改备注</a>
										</td>
									</tr>
									<tr class="InnerTableContent">
										<td height="25">折扣:<s:property
												value="uiBean.financeBill.invoiceDiscount" /></td>
										<td>上欠:<s:property value="uiBean.financeBill.preAcctAmt" /></td>
										<td>下欠 ： <s:property
												value="uiBean.financeBill.postAcctAmt" /></td>
									</tr>
								</table>
							</td>
						</tr>

						<tr class="InnerTableContent">
							<td height="4" colspan="7"><hr width="100%" color="#FFCC00" /></td>
						</tr>
						<tr>
							<td><table width="100%" align="left" class="OuterTable"
									id="org_table">
									<tr class="PBAInnerTableTitale" align='left'>
										<th width="60" height="35">序号</th>
										<th width="110">账户名称</th>
										<th width="120">金额</th>
										<th width="199">说明</th>
									</tr>
									<s:iterator value="uiBean.financeBill.financeBillItemList"
										status="st" id="billItem">
										<s:if test="#billItem.total != 0">
										<tr class="InnerTableContent"
											<s:if test="#st.even">style="<%=Common_util.EVEN_ROW_BG_STYLE %>"</s:if>>
											<td height="25"><s:property value="#st.index + 1" /></td>
											<td><s:property
													value="#billItem.financeCategory.itemName" /></td>
											<td><s:property value="#billItem.total" /></td>
											<td><s:property value="#billItem.comment" /></td>
										</tr>
										</s:if>
									</s:iterator>
									<tr align='left' class="PBAInnerTableTitale">
										<td height="35" colspan="2">总计</td>
										<td><s:property value="uiBean.financeBill.invoiceTotal" /></td>
										<td></td>
									</tr>
								</table></td>
						</tr>
						<tr class="InnerTableContent">
							<td height="4" colspan="7">
							<s:if test="#session.LOGIN_USER.containFunction('financeHQJSP!editFHQBill') && formBean.canEdit">						
									<a id="updateBtn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="editBill();">修改单据</a>
							</s:if> 
							<s:if test="#session.LOGIN_USER.containFunction('financeHQJSP!cancelFHQBill') && formBean.canCancel">				
									<a id="cancelBtn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-no'" onclick="cancelBill();">红冲单据</a>
							</s:if>
							 <s:if test="formBean.canCancel">
							 	<a id="cancelBtn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" onclick="printDocument(true,<s:property value="uiBean.financeBill.id" />);">预览打印</a>
								<a id="cancelBtn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" onclick="printDocument(false,<s:property value="uiBean.financeBill.id" />);">单据打印</a>
							 </s:if>
								
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr class="InnerTableContent">
				<td height="4" colspan="7"><hr width="100%" color="#FFCC00" /></td>
			</tr>
		</table>
	</s:form>
</body>
</html>